﻿namespace Microsoft.SharePoint.Client.Utilities
{
    using Microsoft.SharePoint.Client;
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.Utilities.PrincipalInfo", ValueObject=true, ServerTypeId="{c88e4d2e-768d-4065-9da4-d2880e08733e}")]
    public sealed class PrincipalInfo : ClientValueObject
    {
        private string m_department;
        private string m_displayName;
        private string m_email;
        private string m_jobTitle;
        private string m_loginName;
        private string m_mobile;
        private int m_principalId;
        private Microsoft.SharePoint.Client.Utilities.PrincipalType m_principalType;
        private string m_sIPAddress;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = false;
            switch (peekedName)
            {
                case "PrincipalType":
                    flag = true;
                    reader.ReadName();
                    this.m_principalType = reader.ReadEnum<Microsoft.SharePoint.Client.Utilities.PrincipalType>();
                    return flag;

                case "LoginName":
                    flag = true;
                    reader.ReadName();
                    this.m_loginName = reader.ReadString();
                    return flag;

                case "PrincipalId":
                    flag = true;
                    reader.ReadName();
                    this.m_principalId = reader.ReadInt32();
                    return flag;

                case "Email":
                    flag = true;
                    reader.ReadName();
                    this.m_email = reader.ReadString();
                    return flag;

                case "SIPAddress":
                    flag = true;
                    reader.ReadName();
                    this.m_sIPAddress = reader.ReadString();
                    return flag;

                case "Mobile":
                    flag = true;
                    reader.ReadName();
                    this.m_mobile = reader.ReadString();
                    return flag;

                case "DisplayName":
                    flag = true;
                    reader.ReadName();
                    this.m_displayName = reader.ReadString();
                    return flag;

                case "Department":
                    flag = true;
                    reader.ReadName();
                    this.m_department = reader.ReadString();
                    return flag;

                case "JobTitle":
                    flag = true;
                    reader.ReadName();
                    this.m_jobTitle = reader.ReadString();
                    return flag;
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "PrincipalType");
            DataConvert.WriteValueToXmlElement(writer, this.PrincipalType, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "LoginName");
            DataConvert.WriteValueToXmlElement(writer, this.LoginName, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "PrincipalId");
            DataConvert.WriteValueToXmlElement(writer, this.PrincipalId, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Email");
            DataConvert.WriteValueToXmlElement(writer, this.Email, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "SIPAddress");
            DataConvert.WriteValueToXmlElement(writer, this.SIPAddress, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Mobile");
            DataConvert.WriteValueToXmlElement(writer, this.Mobile, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "DisplayName");
            DataConvert.WriteValueToXmlElement(writer, this.DisplayName, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Department");
            DataConvert.WriteValueToXmlElement(writer, this.Department, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "JobTitle");
            DataConvert.WriteValueToXmlElement(writer, this.JobTitle, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public string Department
        {
            get
            {
                return this.m_department;
            }
        }

        [Remote]
        public string DisplayName
        {
            get
            {
                return this.m_displayName;
            }
        }

        [Remote]
        public string Email
        {
            get
            {
                return this.m_email;
            }
        }

        [Remote]
        public string JobTitle
        {
            get
            {
                return this.m_jobTitle;
            }
        }

        [Remote]
        public string LoginName
        {
            get
            {
                return this.m_loginName;
            }
        }

        [Remote]
        public string Mobile
        {
            get
            {
                return this.m_mobile;
            }
        }

        [Remote]
        public int PrincipalId
        {
            get
            {
                return this.m_principalId;
            }
        }

        [Remote]
        public Microsoft.SharePoint.Client.Utilities.PrincipalType PrincipalType
        {
            get
            {
                return this.m_principalType;
            }
        }

        [Remote]
        public string SIPAddress
        {
            get
            {
                return this.m_sIPAddress;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{c88e4d2e-768d-4065-9da4-d2880e08733e}";
            }
        }
    }
}

